/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 bitmap_raw.h

	$Header: /heroes4/bitmap_raw.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( BATTLEFIELD_PRESET_MAP_H_INCLUDED )
#define BATTLEFIELD_PRESET_MAP_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "battlefield_passablity_map.h" 
#include "bitmap_layer.h"
#include "screen_point.h"

#include "memory_bitmap.h"
#include "memory_bitmap_typedef.h"

class t_battlefield_preset_map_in_game;

/////////////////////////////////////////////////////////////////////////////
// bitmap_raw class handles the load/save of raw 24 bit bitmaps.

//this bitmap raw class is used by the editor
	
class t_battlefield_preset_map
{
	friend class t_battlefield_preset_map_in_game;

public:
	
	// Constructors / Destructor
	t_battlefield_preset_map();
	virtual ~t_battlefield_preset_map();
	
	// Member functions	
	bool								read( std::streambuf& buffer);
	bool								write( std::streambuf& buffer ) const;
	
	void								initialize_passability_map(
												int						map_size,
												int						tile_height,
												t_screen_point const &	view_size);

	void								initialize_backdrop( t_bitmap_layer_24 const &		backdrop_source );
	
	void								set_map_tile( int x, int y, bool val );
	bool								get_map_tile( int x, int y );

	void								clear_passability_map();
	void								calculate_passability_map( 
											t_bitmap_layer_24 const & bitmap,
											t_bitmap_layer_24 const & mask, 
											t_bitmap_layer_24 const & obstacle,
											t_screen_rect max_extent );
	
	t_battlefield_passablity_map_ptr	get_passability_map();
	t_bitmap_layer_24  &				get_backdrop();

protected:

	t_battlefield_passablity_map_ptr	m_passability_map;
	t_bitmap_group_24					m_backdrop_group;
};

inline t_battlefield_passablity_map_ptr t_battlefield_preset_map::get_passability_map() { return m_passability_map;}

inline t_bitmap_layer_24 & t_battlefield_preset_map::get_backdrop() { return m_backdrop_group[0];}

/////////////////////////////////////////////////////////////////////////////

template <>
struct t_resource_traits<t_battlefield_preset_map>
{
	static char const prefix[];
	static char const extension[];
};

/////////////////////////////////////////////////////////////////////////////
#endif // !defined( BATTLEFIELD_PRESET_MAP_H_INCLUDED )
